
var dialog = {
    success: function(data){
        swal({
            title: data.message,
            text: data.info,
            type: "success",

        },function(){
            window.location=data.url
        })
    },
    onesuccess: function(data){
        swal({
            title: data.message,
            text: data.info,
            type: "success",

        })
    },
    error : function(data){
        swal({
            title: data.message,
            text: data.info,
            type: "error"
        });
    }
}

function rr(messags){
    swal({
        title: "Are you sure?",
        text: "You will not be able to recover this imaginary file!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "Yes, delete it!",
        closeOnConfirm: false
    }, function () {
        swal("Deleted!", "Your imaginary file has been deleted.", "success");
    });
}
function tt(messags){
    swal({
            title: "Are you sure?",
            text: "Your will not be able to recover this imaginary file!",
            type: "error",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes, delete it!",
            cancelButtonText: "No, cancel plx!",
            closeOnConfirm: false,
            closeOnCancel: false },
        function (isConfirm) {
            if (isConfirm) {
                swal("Deleted!", "Your imaginary file has been deleted.", "success");
            } else {
                swal("Cancelled", "Your imaginary file is safe :)", "error");
            }
        });
}

(function(){
    $('.attr-del').click(function(){
        var id = $(this).attr('attr-id');
        var message = $(this).attr('attr-message');
        var url = SCOPE.url_del;
        var $this = $(this).parents('tr');
        swal({
                title: "您确定要删除"+message+"?",
                text: "删除后将无法恢复！",
                type: "error",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: false},
                function(){
                    $.post(url,{'id':id},function(msg){
                        if(msg.status == 1){
                            swal(msg.info+'删除成功','', "success");
                            $this.remove();
                        }else{
                            swal(msg.info+'删除成功','', "error");
                        }
                    },'json')
                })

    });

})()
    function accretion(data){
        data = data.serialize();
        $.ajax({
            url:SCOPE.url_form,
            type:'post',
            dataType:'json',
            data:data,
            success:function(msg){
                if(msg.status == 1){
                    dialog.success(msg);
                }else{
                    dialog.error(msg)
                }
            },
            error:function(XmlHttpRequest,textStatus,errorThrown){
                swal(textStatus,'',"error");
            },

        })
        return false;

    }

